<extend name="layout/edit" />

<block name="HEADER">

</block>

<block name="CONTENT">
    <control:form id="refundDetailsForm"/>
</block>

<block name="FOOTER">
   <script type="text/javascript">
	    var  page=(function(ns){
	    	
	    	ns.init = function(){
	    		if( refundDetailsForm.getValue('refund_status') != 1 ){
	    			$("#confirm,#reject").hide();
	    		}
	    	}
	    	
	    	//确认
	       ns.confirm=function(){
	       		var param = refundDetailsForm.getData();
	        	if(!param) return false;
				$.ajaxs("/admin/v1/Order/refund", param, function(res) {
					refundDetailsForm.opener.$.toast(1, "已退款！");
					refundDetailsForm.opener.grid.load();
					$.close();
				});
	        }
	       
	        //驳回
	        ns.reject=function(){
	        	function  yesFn(index){
			        $(".J-changeStatus").validformIn(function(data){ 
			        	var param = refundDetailsForm.getData();
			        	if(!param) return false;
			        	param.desc = data.desc;
						$.ajaxs("/admin/v1/Order/reject", param, function(res) {
							refundDetailsForm.opener.$.toast(1, "已驳回！");
							refundDetailsForm.opener.grid.load();
							layer.close(index);
							$.close();
						});
			        });
			    }
			    let html= template("grid-tpl-reason",{value:''});
			    $.openModalDialog(html,"确认",null,yesFn,["400px","250px"]);
	        }
	        
	        return ns;
	    }({}));
	    
	    
	    $(function(){ page.init();  });
   </script>
</block>



